# -*- coding: utf-8 -*-
"""
@Time : 2024/1/10 13:48
@Author : TJF

"""
import datetime

import os
import time
from urllib.parse import unquote
from requests_toolbelt import MultipartEncoder
import json
import requests
import sweetest.report as report
import sweetest.utility as utility


# 飞书  上传文件到空间的文件夹，需要有自建应用
class SendFeishu:
	def __init__(self, code, plan_name, sheet_name, faicase, blocase, sc, fc, bc, tc):
		self.t_failse_con = ''
		self.image = None  # 上传到飞书服务器的图片  参考：https://open.feishu.cn/document/server-docs/im-v1/image/create
		self.file_url = None  # 文件url
		self.file_name = None  # 文件名
		self.env = None  # 执行环境 如测试环境、生产环境
		self.apiorui = None  # 执行类型 接口 or UI
		self.pro_name = None  # 项目名称如 ：岚图
		self.code = code  # 用例执行状态码
		self.sheet_name = sheet_name  # 用例集
		self.faicase = faicase  # 失败的用例
		self.blocase = blocase  # 阻塞的用例
		self.sc = sc  # success case
		self.fc = fc  # false case
		self.bc = bc  # block case
		self.tc = tc  # total  case
		self.res = None
		# self.err_info = err_info  # testcase中的错误信息
		self.plan_name = plan_name  # 如： LanTu_api_test
		self.parent_node = None  # 测试报告文件夹的token,飞书云文档页面抓包可以看到
		self.url_robot_fs = None  # 飞书群聊机器人的url
		self.url_pro = None  # 项目的url
		self.members = None  # 成员
		self.template = None
		self.tjf_open_id = 'ou_b6a774ccc69b1ef1dec367ee12fab910'  # 用户 ‘谭静飞’ 在飞书中的open_id  （同一用户，不同组织，open_id唯一）
		self.zyy_open_id = 'ou_96cae93795895a71365ee7ab4629aa53'  # 用户 ‘朱洋洋’

	def report_title(self):
		"""
		:return: pro_name:项目名称，apiorui:执行类型，env:执行环境，title:UI执行汇总后缀（_汇总）
		:rtype:
		"""
		# 飞书群发消息时，需要以下内容，目前只有岚图，后期可能会有其他项目，做个判断，
		if 'LanTu' in self.plan_name:
			self.pro_name = '岚图'  # 项目名称
			self.members = f'<at id={self.zyy_open_id}></at><at id={self.tjf_open_id}></at>'  # 项目负责人
			self.image = "img_v3_02a8_9982f539-d1da-43f6-adb1-70d4fd9b794g"
			if 'test' in self.plan_name:
				self.parent_node = 'DKlUfFqNalkEzTd5EJpcGT75nQh'  # 测试报告文件夹的token,飞书云文档页面抓包可以看到
				self.url_robot_fs = 'https://open.feishu.cn/open-apis/bot/v2/hook/0720c99f-d3d3-4c69-9b98-63c7887d7030'  # 飞书群聊机器人url
				self.url_pro = 'http://10.82.66.149:8099/app/acquisitionManagement'  # 岚图项目地址
			elif ('pro' in self.plan_name):
				# self.parent_node = 'GsGUfBBmel1wR7deyYrcXklbnCf'  # 测试报告文件夹的token,飞书云文档页面抓包可以看到
				self.parent_node = 'SxsqfSHQTlqyl0dM4AlcX3YpnEz'  # 测试报告文件夹的token,飞书云文档页面抓包可以看到
				self.url_robot_fs = 'https://open.feishu.cn/open-apis/bot/v2/hook/d47474b2-d1e0-4f63-b747-927f4271875e'  # 飞书群聊机器人url
				self.url_pro = 'http://10.82.9.30:8099/app/acquisitionManagement'  # 岚图项目地址
			else:
				raise Exception('项目名称错误，请检查！！！')

		elif 'Geely' in self.plan_name:
			self.pro_name = '吉利'
			self.parent_node = 'OaNNfO66Hl3GvkdIoCicWyWanRh'
			self.url_robot_fs = 'https://open.feishu.cn/open-apis/bot/v2/hook/714e8bc9-de81-48af-8130-4801e6bdd008'
			self.url_pro = 'http://106.75.247.11:18887/app'  # 吉利项目地址
			self.members = f'<at id={self.tjf_open_id}></at>'
			self.image = 'img_v3_02a8_08e9b685-c1e3-4779-8033-3bf2ffd3bc4g'

		elif 'Hongqi' in self.plan_name:
			self.pro_name = '红旗'
			self.parent_node = 'Xp6lfJRSklNrS0dsgwOc0HgRnLd'
			self.url_robot_fs = 'https://open.feishu.cn/open-apis/bot/v2/hook/714e8bc9-de81-48af-8130-4801e6bdd008'
			self.url_pro = 'http://106.75.217.172:16011/app/home'  # 红旗项目地址
			self.members = f'<at id={self.tjf_open_id}></at>'
			self.image = 'img_v3_02a8_08e9b685-c1e3-4779-8033-3bf2ffd3bc4g'
		else:
			raise Exception('项目名称错误，请检查！！！')

		if 'api' in self.plan_name:
			self.apiorui = '接口'
		elif 'ui' in self.plan_name:
			self.apiorui = 'UI'
		else:
			self.apiorui = ''
		# raise Exception('测试类型错误，请检查！！！')

		if 'test' in self.plan_name:
			self.env = '测试环境'
		elif 'pro' in self.plan_name:
			self.env = '生产环境'
		else:
			self.env = ''
		# raise Exception('执行环境错误，请检查！！！')

		self.title = ''

	# 获取tenant_access_token
	def get_ten_acc_token(self, app_name):
		if app_name == '飞书应用613-自动化结果通知':
			app_id = 'cli_a40d6db44c7c100d'
			app_secret = "Tyc7UJULt9MBBuzaJVtrBcJclwUcbko1"
		elif app_name == '智协慧同-自动化结果通知':
			app_id = 'cli_a73efc93ffdb100d'
			app_secret = "SB5L5v4sZa3Xlq09KGu3Whq4kcDvc3Ub"

		url_token = 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal'
		headers_token = {
			'Content-Type': 'application/json; charset=utf-8',
		}
		data_token = {
			'app_id': app_id,
			'app_secret': app_secret
		}
		response = requests.request('POST', url_token, headers=headers_token, json=data_token)
		self.ten_acc_token = json.loads(response.text)['tenant_access_token']
		return self.ten_acc_token

	# print('this is acc_token', self.ten_acc_token)

	# 上传文件到飞书空间的文件夹下
	def send_file(self):
		# self.file_name = report.md_file_name
		if self.code == 0 and self.bc == 0:
			self.res = "成功"
		elif self.code == 0 and self.bc != 0:
			self.res = "阻塞"
		else:
			self.res = "失败"
		if isinstance(self.sheet_name, list):
			self.sheet_name = self.sheet_name[0]
		self.file_name = self.plan_name + '_' + self.sheet_name + '_' + self.res + '_' + report.re_time + '.md'

		file_path = os.path.abspath(report.md_file_path)
		file_size = os.path.getsize(file_path)
		url_upload = "https://open.feishu.cn/open-apis/drive/v1/files/upload_all"

		payload = {'file_name': self.file_name,
		           'parent_type': 'explorer',
		           'parent_node': self.parent_node,
		           'size': file_size}
		files = [
			('file', (self.file_name, open(file_path, 'rb'), 'application/json'))
		]
		headers_upload = {
			'Authorization': f'Bearer {self.ten_acc_token}'
		}

		response = requests.request("POST", url_upload, headers=headers_upload, data=payload, files=files)

		# 获取上传到飞书文件夹的文件url
		file_url_feishu = (f'https://open.feishu.cn/open-apis/drive/v1/files?direction=DESC&folder_token='
		                   f'{self.parent_node}&order_by=CreatedTime')
		headers_upload = {
			'Authorization': f'Bearer {self.ten_acc_token}'
		}

		response = requests.request("GET", file_url_feishu, headers=headers_upload, data=payload)
		all_info = json.loads(response.text)
		self.files = all_info['data']['files']
		for i in self.files:
			if self.file_name in i['name']:
				self.file_url = i['url']

	def get_file_token(self):
		# 获取第一页 创建时间>=30天 的文件token

		# 获取文件夹下的清单
		# 删除的接口是按创建时间升序排序  查询url的接口是按创建时间降序排序
		file_url_feishu = (f'https://open.feishu.cn/open-apis/drive/v1/files?direction=ASC&folder_token='
		                   f'{self.parent_node}&order_by=CreatedTime')
		headers_upload = {
			'Authorization': f'Bearer {self.ten_acc_token}'
		}

		response = requests.request("GET", file_url_feishu, headers=headers_upload)
		all_info = json.loads(response.text)
		files = all_info['data']['files']
		# print('this is files', files)

		current_timestamp = int(time.time())  # 当前时间戳 10位
		threshold_days = 30  # 超过30天
		self.file_token = []  # 文件token
		for file in files:
			if (current_timestamp - int(file['created_time'])) > (threshold_days * 24 * 60 * 60):
				self.file_token = file['token']
				# print('this is 有大于1天的文件')
				return self.file_token

	def delete_file(self):
		# 删除创建时间>=30天 的文件
		url = f"https://open.feishu.cn/open-apis/drive/v1/files/{self.file_token}?type=file"  # 删除文件/文件夹
		payload = ''
		headers_del = {
			'Authorization': f'Bearer {self.ten_acc_token}'
		}
		response = requests.request("DELETE", url, headers=headers_del, data=payload)

	def is_delete(self):
		# 当飞书文件夹下的has_more：True时，执行：查询文件夹下清单-->删除超过30天的文件
		# 当飞书文件夹下的has_more：False时，不执行
		while True:
			run_delete = self.get_file_token()
			# print('this is filetoken',run_delete)
			if run_delete:
				self.delete_file()
			else:
				break

	def sendmessage_feishu(self):
		# 发送卡片类型的消息到飞书群聊中的机器人
		# 飞书卡片消息  旧版本：https://open.feishu.cn/tool/cardbuilder
		# 飞书卡片消息 新版本：https://open.feishu.cn/cardkit
		if os.getlogin() == '小生活':
			self.user_ids = {'谭静飞': "f8882183"}
			self.url_robot_fs = 'https://open.feishu.cn/open-apis/bot/v2/hook/e25eba9a-76fa-412b-a476-06c46293b765'  # 上班后，消息推送到飞书助手，方便调试，不打扰其他人
		elif os.getlogin() == 'exd_pc':
			self.user_ids = {'谭静飞': "f8882183", '朱洋洋': "3g4d8dgb", '王志娟': "gced1ead", '李磊': "823f1e83",
					'童庆亮': "541cb7e3", '黄锦冲': "bg651784"}

		if not self.file_url:
			self.file_url = f'https://o0wyok2e7n1.feishu.cn/drive/folder/{self.parent_node}'
			self.title = '_汇总'

		if self.code == 0 and self.bc == 0:
			self.template = "green"
			self.result = ":比心: 测试通过 :比心:"
			self.tips = ''
			self.res = "成功"
		elif self.code == 0 and self.bc != 0:
			self.template = "grey"
			self.result = ':晕:<font color="grey"> **有用例阻塞，请注意** </font>:晕: '
			self.tips = '<font color="red"> **请注意查验！！！** </font>'
			self.res = "阻塞"
		else:
			self.template = "red"
			self.result = ":惊呆:<font color=\"red\"> **测试失败** </font>:惊呆: "
			self.tips = '<font color="red"> **请注意查验！！！** </font>'
			self.res = "失败"
		self.t_failse_con = ''
		no = 1

		if self.fc == 0:
			self.t_failse_con = f'<font color=\"red\">失败用例</font>：  \n'
		else:
			for fsheet_name in self.faicase:
				for ftestcase_name in self.faicase[fsheet_name]:
					self.err_info = self.faicase[fsheet_name][ftestcase_name]
					con = f'<font color=\"red\">失败用例{no}</font>：  {fsheet_name}：{self.flatten_list(ftestcase_name)}\n<font color=\"red\">失败描述</font>： {self.err_info}\n'
					self.t_failse_con += con
					no += 1

		#   elements:content中常用的一个参数

		headers = {'content-type': "application/json"}
		content = {
			"msg_type": "interactive",
			"card": {
				"elements": [
					{
						"tag": "div",
						"text": {
							"content": f'功能模块：{self.flatten_list(self.sheet_name)}\n用例总数：  {self.tc}\t条\n<font color=\"green\">成功总数</font>：  {self.sc}\t条\n<font color=\"red\">失败总数</font>：  {self.fc}\t条\n'
							           f'{self.t_failse_con}<font color=\"yellow\">阻塞总数</font>：  {self.bc}\t条\n<font color=\"yellow\">用例名称</font>：  {self.flatten_list(self.blocase)}\n'
							           f'\n测试结果：{self.result}{self.tips}',
							"tag": "lark_md"
						}
					},
					{
						"actions": [{
							"tag": "button",
							"text": {
								"content": f"{self.pro_name}-灵活数采",
								"tag": "lark_md"
							},
							"url": f"{self.url_pro}",
							"type": "default",
							"value": {}
						},
							{
								"tag": "button",
								"text": {
									"content": "自动化测试报告地址",
									"tag": "lark_md"
								},
								"url": self.file_url,
								"type": "default",
								"value": {}
							}
						],
						"tag": "action"
					}],
				"header": {
					"template": self.template,
					"title": {
						"content": f'{self.pro_name}_{self.apiorui}_{self.env}{self.title}',
						"tag": "plain_text"
					}
				}
			}
		}
		if self.code == 0 and self.bc == 0:
			if self.title == '_汇总':
				r = requests.post(url=self.url_robot_fs, data=json.dumps(content), headers=headers)

		else:
			r = requests.post(url=self.url_robot_fs, data=json.dumps(content), headers=headers)
			print(r.text)
			print(r.status_code)


		for user_name, user_id in self.user_ids.items():
			url_personal = "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=user_id"
			headers1 = {
				'Content-Type': 'application/json',
				'Authorization': f"Bearer {self.get_ten_acc_token('智协慧同-自动化结果通知')}"
			}

			data1 = {
				"receive_id": user_id,
				"msg_type": "interactive",
				"content": json.dumps({
					"elements": [
						{
							"tag": "div",
							"text": {
								"content": f'功能模块：{self.flatten_list(self.sheet_name)}\n用例总数：  {self.tc}\t条\n<font color=\"green\">成功总数</font>：  {self.sc}\t条\n<font color=\"red\">失败总数</font>：  {self.fc}\t条\n'
								           f'{self.t_failse_con}<font color=\"yellow\">阻塞总数</font>：  {self.bc}\t条\n<font color=\"yellow\">用例名称</font>：  {self.flatten_list(self.blocase)}\n'
								           f'\n测试结果：{self.result}{self.tips}',
								"tag": "lark_md"
							}
						},
						{
							"actions": [{
								"tag": "button",
								"text": {
									"content": f"{self.pro_name}-灵活数采",
									"tag": "lark_md"
								},
								"url": f"{self.url_pro}",
								"type": "default",
								"value": {}
							},
								{
									"tag": "button",
									"text": {
										"content": "自动化测试报告地址",
										"tag": "lark_md"
									},
									"url": self.file_url,
									"type": "default",
									"value": {}
								}
							],
							"tag": "action"
						}],
					"header": {
						"template": self.template,
						"title": {
							"content": f'{self.pro_name}_{self.apiorui}_{self.env}{self.title}',
							"tag": "plain_text"
						}
					}
				})  # 将 content 转换为 JSON 字符串
			}

			# 确保请求体是有效的 JSON 格式
			data2 = json.dumps(data1)
			if self.code == 0 and self.bc == 0:
				if self.title == '_汇总':
					r = requests.post(url=url_personal, data=data2, headers=headers1)
			else:
				r = requests.post(url=url_personal, data=data2, headers=headers1)

				print(f'推送结果：{r.status_code}_{user_name}')

	def send_to_personal(self):
		# ↓↓↓发型消息给个人
		# user_ids = {'谭静飞': "f8882183", '朱洋洋': "3g4d8dgb", '王志娟': "gced1ead", '李磊': "823f1e83",
		#             '童庆亮': "541cb7e3", '黄锦冲': "bg651784"}

		# ↑↑↑发型消息给个人

		pass

	def send_news_feishu(self):
		common_back = common()
		title1, url1, title2, url2, title3, url3 = common_back.get_internal_news()
		date, week, wea, tem1, tem2, air_tips = common_back.get_weather()

		# 发送国内要闻
		now = datetime.datetime.now().time()
		time_8_30 = datetime.time(8, 30, 0)

		if now > time_8_30:
			self.url_robot_fs = 'https://open.feishu.cn/open-apis/bot/v2/hook/e25eba9a-76fa-412b-a476-06c46293b765'  # 飞书助手

		headers = {'content-type': "application/json"}
		# print('this is url ', url1)
		# print('this is url ', url2)
		# print('this is url ', url3)
		content = {
			"msg_type": "interactive",
			"card": {
				"elements": [
					{
						"tag": "div",
						"text": {
							"content": f"<font color='green'>**{date}\t{week}\t{wea}\t{tem2}  ~  {tem1}  ℃\n{air_tips}** </font> ",
							"tag": "lark_md"
						}
					},
					{
						"tag": "action",
						"actions": [
							{
								"tag": "button",
								"text": {
									"content": f'{title1}',
									"tag": "lark_md"
								},
								"url": f"{url1}",
								"type": "flow",
								"value": {}
							},
						], "layout": "flow"
					},
					{
						"tag": "action",
						"actions": [
							{
								"tag": "button",
								"text": {
									"content": f'{title2}',
									"tag": "lark_md"
								},
								"url": f"{url2}",
								"type": "flow",
								"value": {}
							},
						], "layout": "flow"
					},
					{
						"tag": "action",
						"actions": [
							{
								"tag": "button",
								"text": {
									"content": f'{title3}',
									"tag": "lark_md"
								},
								"url": f"{url3}",
								"type": "flow",
								"value": {}
							},
						], "layout": "flow"
					},

				],
				"header": {
					"template": "blue",
					"title": {
						"content": '测试结束啦~~~',
						"tag": "plain_text"
					}
				}
			}
		}
		r = requests.post(url=self.url_robot_fs, data=json.dumps(content), headers=headers)

	# print(r.text)

	def flatten_list(self, input_list):  # 发送到飞书群由 ['data1'、'data2'、'data3']  变成  data1、data2、data3
		def _flatten_list(input_list):
			# 遍历列表，使得列表中的元素都是单个的字符串
			self.final_list = []
			if isinstance(input_list, str):
				input_list = [input_list]

			for item in input_list:
				if isinstance(item, str):
					self.final_list.append(item)
				elif isinstance(item, list):
					self.final_list.extend(item)
				else:
					print(f'{input_list} type wrong')
			return self.final_list

		final_str = '、'.join(_flatten_list(input_list))
		return final_str

	def run(self):
		self.report_title()
		# self.get_ten_acc_token('飞书应用613-自动化结果通知')
		self.get_ten_acc_token('智协慧同-自动化结果通知')
		self.send_file()
		self.sendmessage_feishu()
		self.is_delete()

	def run_finnal(self):
		self.flatten_list(self.faicase)
		# self.flatten_list(self.blocase)
		self.report_title()
		self.sendmessage_feishu()


# self.send_news_feishu()


class SendQiwei:
	def __init__(self):
		pass

	def sendmessage(code, name, sheet_name):
		headers = {'content-type': "application/json"}
		url = "https://open.feishu.cn/open-apis/bot/v2/hook/3c1da9e7-aaca-45f4-92da-2a9ff06db8e9"  # 自动化用例执行结果
		# url = 'https://open.feishu.cn/open-apis/bot/v2/hook/204c7253-0602-4177-aa28-28d50ae476bf'  # 飞书助手

		if code == 0:
			result = ':比心  :测试通过:  比心:'
			content = {
				"msg_type": "text",
				"content": {
					"text": f"项目名称： {name}\n功能：{sheet_name}\n测试结果：{result}"
				}
			}
			r = requests.post(url=url, data=json.dumps(content), headers=headers)
		else:
			result = ':晕  :测试未通过:  晕:'
			content = {
				"msg_type": "text",
				"content": {
					"text": f"项目名称： {name}\n功能：{sheet_name}\n测试结果：{result}"
				}
			}
			r = requests.post(url=url, data=json.dumps(content), headers=headers)

	'''
	企微机器人模版
		if code == 1:
			result = "测试通过"
			content = {
				"msgtype": "markdown",
				"markdown": {
					"content": "<font color=\"green\">%s</font>"%("自动化测试用例：" + name + "\n" + "功能：" + ("'" + "','".join(sheet_name) + "'") + "\n测试结果：" + result)
					# "mentioned_mobile_list": ["18939881330", "17320087073"]
				}
			}
			r = requests.post(url=url, data=json.dumps(content), headers=headers)
			print(r.text + "test")
		else:
			result = "测试失败"
			content = {
				"msgtype": "markdown",
				"markdown": {
					"content":"<font color=\"red\">%s</font><>"%( "自动化测试用例：" + name + "\n" + "功能：" + ("'" + "','".join(sheet_name) + "'") + "\n测试结果：" + result),
					# "mentioned_mobile_list": ["18939881330","17320087073"]
				}
			}
			r = requests.post(url=url, data=json.dumps(content), headers=headers)
			print(r.text+"test")
			'''

	def sendFile(file_id):
		url = "https://open.feishu.cn/open-apis/bot/v2/hook/3c1da9e7-aaca-45f4-92da-2a9ff06db8e9"
		# url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6c6335c9-2408-4f3b-9333-bcbaff4f656c"

		headers = {'content-type': "application/json"}
		content = {
			"msgtype": "file",
			"file": {
				"media_id": file_id
			}
		}
		s = requests.post(url=url, data=json.dumps(content), headers=headers)

	# 企微
	def uploadFile(filepath, filename, access_token):
		post_file_url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key={access_token}&type=file"
		# post_file_url =f"https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key=6c6335c9-2408-4f3b-9333-bcbaff4f656c&type=file"

		# m = MultipartEncoder(fields:{filename: ('file', open(filepath + Autotest., 'rb'), 'text/plain')})

		m = MultipartEncoder(
			fields={filename: (filename, open(filepath, 'rb'))},
		)
		print(m)
		r = requests.post(url=post_file_url, data=m, headers={
			'Content-Type': "multipart/form-data"})
		print(r.text)
		return r.json()['media_id']

	def sendRequest(serverUrl, result, uuId):
		headers = {'Content-Type': "application/json"}
		content = {
			"uuId": uuId,
			"result": result
		}
		print("更新平台状态成功")
		print(requests.post(serverUrl, json.dumps(content), headers=headers).text)


class send_dingding:
	def __init__(self):
		pass


class common:
	def __init__(self):
		pass

	def get_internal_news(self):
		# 获取国内要闻
		url = ("https://www.toutiao.com/hot-event/hot-board/?origin=toutiao_pc&_signature=_"
		       "02B4Z6wo00901k0-0dwAAIDDS85Px3t3bMpNGtVAAPV3cVhD0nBRGmfYYLWzlOdvdpaGWcwUgMNVqBFFQQudNnmhgAt4CmWZTrRY"
		       "-rABnw4thuYA.7ViFiBn5p8jK0b5JLSQ6AkKTSmdzFlk34")
		payload = {}
		headers = {}
		response = requests.request("GET", url, headers=headers, data=payload)
		data = json.loads(response.text)
		# 获取第一条新闻标题和url
		title1 = data['data'][0]["Title"]
		url1 = unquote(data['data'][0]["Url"])

		# 获取第二条新闻标题和url
		title2 = data['data'][1]["Title"]
		url2 = unquote(data['data'][1]["Url"])

		# 获取第三条新闻标题和url
		title3 = data['data'][2]["Title"]
		url3 = unquote(data['data'][2]["Url"])

		return title1, url1, title2, url2, title3, url3

	def get_weather(self):
		'''

		:return: date:时间，week:星期，wea:晴雨，tem1：最低温度，tem2:最高温度，air_tip:温馨提示
		:rtype:
		'''
		# 获取上海当天的天气情况
		appid = '83142338'
		appsecret = 'kqeS5lgX'
		url = f'http://v0.yiketianqi.com/api?unescape=1&version=v63&appid={appid}&appsecret={appsecret}'
		r = requests.request('GET', url)
		data = json.loads(r.text)
		date = data['date']
		week = data['week']
		wea = data['wea']
		air_tips = data['air_tips']
		tem1, tem2 = data['tem1'], data['tem2']
		return date, week, wea, tem1, tem2, air_tips

	def get_chinese_calendar(self):
		"""

		:return:
		:rtype:
		"""
		# 黄历
		current_datetime = datetime.datetime.now()

		url = (f"https://www.nongli.cn/index.php?m=content&c=index&a=ajaxPair"
		       f"&year={current_datetime.year}&month={current_datetime.month}&date={current_datetime.day}")
		payload = {}
		response = requests.request("GET", url, data=payload, verify=False)
		data = json.loads(response.text)
		print(data)
		print('今天是农历', data['lunar_calendar'][0][7:])
		print('今天宜：', data['appropriate'])
		print('今天忌：', data['avoid'])
